package collection;

import com.sun.media.sound.SoftTuning;

import javax.sound.midi.Soundbank;
import java.util.ArrayList;
import java.util.Collection;

/**
 * Collection接口的演示
 */
public class CollectionDemo {
    public static void main(String[] args) {
       /* Collection c = new ArrayList();
        c.add(new Point(10, 20));
        c.add(new Point(30, 40));
        c.add(new Point(50, 60));
        c.add(new Point(70, 80));
        c.add(new Point(90, 90));
        c.add(new Point(70, 80));
        System.out.println(c);
        Point p = new Point(70, 80);
        boolean contains = c.contains(p);
        //重写前:  System.out.println(contains);//false,需要重写equals(),因为比较的是当前元素的地址
        System.out.println(contains);//重写后

        c.remove(p);
        System.out.println(c);
       boolean b1= c.remove(p);
        System.out.println(b1+"删除成功"+c);*/


        //集合装的是元素的地址
        Collection cc = new ArrayList();
        Point ll = new Point(1, 2);
        cc.add(ll);//将ll添加到cc中--------将ll的引用装到了cc中
        System.out.println("ll" + ll);//ll(1,2)
        System.out.println("cc" + cc);//cc[(1,2)]

        ll.setX(100);
        System.out.println(ll);//(100,2)
        System.out.println(cc);//(100,2)











        /*Collection c = new ArrayList();
        c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        c.add("five");
        //集合重写了Object的toString()方法
        System.out.println(c);
        System.out.println(c.size());
        System.out.println("集合是否为空" + c.isEmpty());

        c.clear();//清空集合
        System.out.println("集合清空");
        System.out.println(c);
        System.out.println(c.size());
        System.out.println("集合是否为空"+c.isEmpty());*/

    }
}
